<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('收租待办')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>楼栋：</label>-->
<!--                                <input type="text" name="buildingName"/>-->
<!--                            </li>-->
                            <li>
                                <label>单元号：</label>
                                <input type="text" name="unitNameStr"/>
                            </li>
                            <li>
                                <label>租户名称：</label>
                                <input type="text" name="tenantName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:tenant:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:tenant:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:backlog:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-primary" onclick="completeView()" shiro:hasPermission="system:backlog:completeView">
                    <i class="fa fa-arrows"></i> 已收租列表
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var removeFlag = [[${@permission.hasPermi('system:backlog:remove')}]];
        var confirmFlag = [[${@permission.hasPermi('system:backlog:confirm')}]];
        var datas = [[${@dict.getType('sys_backlog_status')}]];
        var prefix = ctx + "system/backlog";

        function completeView(){
            var url = prefix + "/complete";
            $.modal.openTab("已收租列表",url);
        }

        $(function() {

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "收租",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'backlogId',
                    title: '待收租编号',
                    visible: false
                },
                {
                    field: 'tenantId',
                    title: '合同编号',
                    visible: true
                },
                {
                    field: 'buildingName', 
                    title: '楼栋'
                },
                {
                    field: 'unitNameStr', 
                    title: '单元号'
                },
                {
                    field: 'tenantName', 
                    title: '租户名称'
                },
                {
                    field: 'tenantArea',
                    title: '租户面积'
                },
                {
                    field: 'backlogTime',
                    title: '待收租日期'
                },
                {
                    field: 'backlogStatus',
                    title: '收租状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.tenantId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + confirmFlag + '" href="javascript:void(0)" onclick="confirmView(\'' + row.tenantId + '\',\'' + row.backlogId + '\')"><i class="fa fa-edit"></i>收租</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.backlogId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function confirmView(tenantId,backlogId){
            var url = prefix + "/confirm/{tenantId}/{backlogId}";
            var confirmUrl = url.replace("{tenantId}", tenantId).replace("{backlogId}", backlogId);
            $.modal.open("确认收租",confirmUrl);
        }

    </script>
</body>
</html>